package com.xin.bi.exception;

import com.xin.bi.common.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(BusinessException.class)
    public BaseResponse<?> businessExceptionHandler(BusinessException businessException){
        log.error("BusinessException",businessException);
        return new BaseResponse<>(false,null,businessException.getMessage());
    }
    @ExceptionHandler(RuntimeException.class)
    public BaseResponse<?> runtimeExceptionHandler(RuntimeException runtimeException){
        log.error("RuntimeException",runtimeException);
        return new BaseResponse<>(false,null,runtimeException.getMessage());
    }
}
